#! /bin/sh

set -x
## Andreas Rueger March 02, 1997
## Ray tracing in homogeneous anisotropic media
## Type the name of the executable to get
## on-line documentation


### output files
### Change these paths or define your own scratch 
### directory

#####  Data directory
#SCRATCH=/home/user1/Scratch
#
file=elamod

#####  Path to executables
#B=${HOME}/Release/Rays/bin


## Plotting parameters
hbox=2.2 wbox=5

## Model dimension
xmax=5.0 zmax=2.2

## Number of phase angles, anglerange 
nangle=400 fangle=-89.0 langle=89.9 nplotr=$nangle

## Source coordinates
xs=2.5 zs=0.0

## number of points per plot, need to be increased
## for more complex raypaths
nxz=5

## Wavefront time. If you want to plot more than 
## one wavefront, you need to use the nt-parameter
tw=0.6

## wave mode (0=P 1=SV 2=SH)
mode=0

## elastic parameters
vp1=2.6 vs1=2.0 e1=.15 d1=-.1 g1=0.1 a1=0.0 dens=2.7

## title=""

## Built the model. This model builder is very similar
## to the one described in CWP-U26
elamodel xmin=0 zmin=0 xmax=$xmax zmax=$zmax maxangle=5 \
1	xedge=0,5 \
	zedge=0,0 \
2	xedge=0,5 \
	zedge=$zmax,$zmax \
	fill=0.5,0.1,$vp1,$vs1,$e1,$d1,$g1,$a1,$dens \
	kedge=1,2 \
	>$file.model

# generate PostScript output
elaps <$file.model  gtri=-1 \
	hbox=$hbox wbox=$wbox gmin=0.1 gmax=0.7 \
	title=$title \
	>$file.modeleps

####   shoot rays
#### infofile can get rather big. Delete the infofile
#### parameter for speedup and if you have memory
#### problems

elaray <$file.model >$file.endbin \
        rayfile=$file.ray  wavefile=$file.wave\
        nangle=$nangle mode=$mode \
        nxz=$nxz xs=$xs zs=$zs infofile=$file.info\
        fangle=$fangle langle=$langle \
	tw=$tw refseq=2,-1

## Just plot every 5th ray
subset <$file.ray >$file.temp n1=2 n2=$nxz n3=$nangle id3s=5

####   plot the rays with CWP graphics
psgraph <$file.temp \
        n=$nxz nplot=80  \
	hbox=$hbox wbox=$wbox \
	title=$title \
	x1beg=0 x1end=$zmax x2beg=0 x2end=$xmax \
        style=seismic linegray=0 >$file.rayeps


## You need to transpose the file if you use the <nt> option
transp <$file.wave >$file.twave n1=1 n2=$nangle nbpe=8

####    plot the wavefronts
psgraph <$file.twave >$file.waveeps  \
	linewidth=0 mark=8 marksize=4 \
        nplot=1 n=$nangle hbox=$hbox wbox=$wbox \
	title=$title linegray=1\
        x1beg=0 x1end=$zmax x2beg=0 x2end=$xmax \
        style=seismic 

### Here you merge the model/rays/wavefronts 
$CWPROOT/bin/psmerge in=$file.modeleps in=$file.rayeps in=$file.waveeps > $file.all

### You may want to use <gs> instead
ghostview $file.all &


exit 0
